package com.sluggard.mp.properties;

import com.sluggard.mp.model.constants.MybatisPlusConfigConstants;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

/**
 * myabtis plus配置参数
 *
 * @author lizheng
 * @since 2024.4.17
 */
@Data
@Validated
@ConfigurationProperties(prefix = MybatisPlusConfigConstants.MYBATIS_PLUS_PROPERTIES)
public class MybatisPlusConfigProperties {

    /**
     * 开启分页插件，默认启用
     */
    private Boolean enablePage;

    /**
     * 开启乐观锁插件，默认不启用
     */
    private Boolean enableOptimisticLocker;

    /**
     * 开启防全表删除和更新插件，默认启用
     */
    private Boolean enableBlockAttack;

    /**
     * 开启字段转换拦截器，默认不开启
     */
    private Boolean enableFieldConvertInterceptor;

    /**
     * 制定字段转换拦截器实现类
     */
    private String fieldConvertInterceptorImpl;

    /**
     * 逻辑删除字段
     */
    private String logicalDeleteColumn;

    /**
     * 单次最大删除数
     */
    private Integer maxDeleteNum;


    public MybatisPlusConfigProperties() {
        enablePage = true;
        enableOptimisticLocker = false;
        enableBlockAttack = true;
        enableFieldConvertInterceptor = false;
        logicalDeleteColumn = "deleted";
        maxDeleteNum = 200;
    }
}
